Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rishav/52 : adding cleanup and commands left in /health #54

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

rishavvajpayee
Copy link
Contributor

@rishavvajpayee rishavvajpayee commented Nov 6, 2024

  1. Added cleanup and commands left in /health
  2. cleaned time difference code check.

( not added tests )

@rishavvajpayee rishavvajpayee changed the title Rishav/52 Rishav/52 : adding cleanup and commands left in /health Nov 6, 2024
func (s *HTTPServer) getCommandsLeft() (int64, error) {
configValue := config.LoadConfig()
currentWindow := time.Now().Unix() / int64(configValue.Server.RequestWindowSec)
key := fmt.Sprintf("request_count:%d", currentWindow)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can reuse this part of the function @rishavvajpayee

@aasifkhan7
Copy link
Contributor

@rishavvajpayee Currently, x-next-cleanup-time returns the number of seconds remaining until the next cleanup. However, in this PR, it seems you're setting it to represent the exact timestamp of the next cleanup in the health check endpoint.

}

w.Header().Set("x-next-cleanup-time", strconv.FormatInt(nextCleanup, 10))
w.Header().Set("x-commands-left", strconv.FormatInt(commandsLeft, 10))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rishavvajpayee To enable Chrome or other browsers to access certain response headers, you need to include them in the Access-Control-Expose-Headers header. This ensures the specified headers are accessible to client-side scripts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants